﻿using Md.Api.Model.Manage.SysConfig.Request;
using Md.Dapper.Repositories.Md;

namespace Md.Api.Service.Manage.SysConfig;
/// <summary>
/// 通过配置编号删除系统配置服务
/// </summary>
public class DeleteSysConfigByConfigIdService : ApiBase<RequestDeleteSysConfigByConfigIdModel>
{
    /// <summary>
    /// 系统配置仓储
    /// </summary>
    public SysConfigRep sysConfigRep { get; set; }
    /// <summary>
    /// 执行
    /// </summary>
    protected override void ExecuteMethod()
    {
        var ids = Parameter.ConfigIds.Split(",");

        if (ids.Length == 0)
        {
            throw new AggregateException("配置编号不能为空");
        }

        int res = 0;

        foreach (var id in ids)
        {
            var delRes = sysConfigRep.DeleteSysDictDataByDictCode(Convert.ToInt32(id));

            res += delRes;
        }

        Result.Data = res;
    }
}

